package com.lnsf.dao;
import java.awt.event.InputEvent;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import com.lnsf.entity.Goods;

public interface GoodsDao extends JpaRepository<Goods, Integer>{
	
	@Modifying
	@Transactional
	@Query(value="update goods  set name=?2 where id=?1" ,nativeQuery=true)
	public int update(int id, String name);
	
	/*
	 * 2017-7-27
	 * author:华炎
	 * 添加根据用户Id获取商品,Dao层
	 */
	@Query(value="select g from Goods g where g.user.id = :userid")
	public List<Goods> findGoodsByUser(@Param("userid") Integer userid);
	
}
